<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // let arr = [1,2,3]
    // function handleArrOfMap(arr) {
    //   let newArr = arr.map(item => item * 2)
    //   arr = newArr
    // }
    // handleArrOfMap(arr)
    // console.log(arr)
    // function handleArrOfForEach(arr) {
    //   arr.forEach((item,index) => {
    //    arr[index] = item * 2
    //   })
    //   console.log(arr)
    // }
    // handleArrOfForEach(arr)
    // let obj = {'a': 'aaa','b': 'bbb'}
    // let arr2 = []
    // for(let i in obj) {
    //   arr2.push({key: i,value: obj[i]})
    // }
    // console.log(arr2)
    let str = 'acccsdsd'
    let obj = {}
    for (let i = 0; i < str.length; i++) {
      key = str[i]
      if (obj[key]) {
        obj[key]++
      } else {
        obj[key] = 1
      }
    }
    let arr = Object.keys(obj)
    let maxNum = 0
    let maxZimu = ''
    let origin =  0
    arr.forEach((item,index) => {
      if(index === 0) {
        origin = obj[item]
        maxZimu = item
      }
      if(obj[item] > origin) {
        origin = obj[item]
        maxZimu = item
      }
      maxNum = origin
    })
    console.log('最大数'+maxNum,'最大字母是'+maxZimu)
  </script>
</body>

</html>